import React, { Component } from 'react'
export default class App extends Component {
  usernameRef = React.createRef()
  getData = () => {
    console.log(this.usernameRef.current.value)
  }
  render() {
    return (
      <div>
        <input ref={ this.usernameRef } type="text" placeholder="用户名" />
        <button onClick={ this.getData }>获取数据</button>
      </div>
    )
  }
}
